/**
 * 字符串递增
 * @param  {string} prefix         字符串前缀，若无前缀则传''
 * @param  {number} digit          位数，从1开始
 * @example
 * 	// todo: need unit tests
 * 	feidao.str_increasing('S01', 'S', 2);//S02
 * 	feidao.str_increasing('01', '', 3);//002
 */
export default function increasing(str: string, prefix: string, digit: number) {
	const v2 = str.replace(prefix, '');
	let v3 = parseInt(v2, 10) + 1 + '';
	const v3len = v3.length;
	let v5 = '';
	if (digit > v3len) {
		for (let i = 0; i < (digit - v3len); i++) {
			v5 = '0' + v5;
		}
		v3 = v5 + v3;
	}
	return prefix + v3;
}
